home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 July
/
EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso
/
recent1
/
wwwcount2.3src.lha
/
wwwcount2.3
/
Gen-conf
< prev
next >
Wrap
Text File
|
1996-05-03
|
12KB
|
490 lines
#!/bin/sh
###
# $Revision: 2.3 $
# $Date: 1996/05/03 02:20:22 $
#
# Automatically generate the conter configuration file
###
Version="2.3"
ConfFile="count.cfg"
nick=0
ignc=0
alfc=0
strict=0
rgb=0
(echo "hi there\c" ; echo " ") >.echotest
if grep c .echotest >/dev/null 2>&1 ; then
n='-n'
c=''
else
n=''
c='\c'
fi
rm -f .echotest >/dev/null 2>&1
cat << EOSI
Welcome to the conf file generation procedure of Count $Version
This program creates a workable conf file for your host only, you have
to edit it by hand if you want to add other hosts. The file will have
enough comments in it to help you out. You also have to hand edit it
if you want to use netmasks to mask out a entire network or a specific
range of hosts in a network.
First of all you must know your
1) fully qualified domain name (FQDN), for example,
if your hostname is foo and your domain name is foobar.com,
then your FQDN is
foo.foobar.com
2) IP address of your host, for example,
192.165.155.2
3) If your host has any nickname defined, for example,
www.foobar.com. The nick name also has to be FQDN.
4) If you want to allow automatic datafile creation (bad thing).
5) If you want to run the counter in strict mode.
6) If you want to ignore access hits from your own host.
EOSI
echo $n "Continue [y|n]$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
do
echo $n "Continue [y|n]$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
done
case $answer in
y|Y)
######
# Enter hostname --Starts
#####
cat<<EOE
No Error checking will be done with your hostname, therfore,
you better make sure you are entering the fully qualifed domain name.
EOE
echo $n "* Enter your fully qualified domain name [no default]:$c "
read hostname
host=`echo $hostname|awk -F. '{print $1}'`
dom1=`echo $hostname|awk -F. '{print $2}'`
dom2=`echo $hostname|awk -F. '{print $3}'`
until [ .$hostname != . -a .$host != . -a .$dom1 != . -a .$dom2 != . ]
do
echo $n "* Enter your fully qualified domain name [no default]:$c "
read hostname
host=`echo $hostname|awk -F. '{print $1}'`
dom1=`echo $hostname|awk -F. '{print $2}'`
dom2=`echo $hostname|awk -F. '{print $3}'`
done
######
# Enter hostname --Ends
#####
######
# Enter ip address --Starts
#####
cat<<EOE
No Error checking will be done with your IP address, therfore,
you better make sure you are entering the correct IP address.
EOE
echo $n "* Enter your IP address [no default]:$c "
read ipaddress
oct1=`echo $ipaddress|awk -F. '{print $1}'`
oct2=`echo $ipaddress|awk -F. '{print $2}'`
oct3=`echo $ipaddress|awk -F. '{print $3}'`
oct4=`echo $ipaddress|awk -F. '{print $4}'`
until [ .$ipaddress != . -a .$oct1 != . -a .$oct2 != .\
-a .oct3 != . -a .$oct4 != . ]
do
echo $n "* Enter your IP address [no default]:$c "
read ipaddress
oct1=`echo $ipaddress|awk -F. '{print $1}'`
oct2=`echo $ipaddress|awk -F. '{print $2}'`
oct3=`echo $ipaddress|awk -F. '{print $3}'`
oct4=`echo $ipaddress|awk -F. '{print $4}'`
done
######
# Enter ip address --Ends
#####
######
# ask for nick --Starts
#####
echo ""
echo $n "* Does your host have any nickname [y|n]:$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
do
echo $n "* Does your host have any nickname (FQDN) [y|n]:$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
done
case $answer in
y|Y)
nick=1
echo $n "* Enter your host's nickname (FQDN) [no default]:$c "
read nickname
nhost=`echo $nickname|awk -F. '{print $1}'`
ndom1=`echo $nickname|awk -F. '{print $2}'`
ndom2=`echo $nickname|awk -F. '{print $3}'`
until [ .$nickname != . -a .$nhost != . -a .$ndom1 != . -a .$ndom2 != . ]
do
echo $n "* Enter your host's nickname [no default]:$c "
read nickname
nhost=`echo $nickname|awk -F. '{print $1}'`
ndom1=`echo $nickname|awk -F. '{print $2}'`
ndom2=`echo $nickname|awk -F. '{print $3}'`
done
;;
n|N)
;;
*)
echo "Illegal choice"
esac
until [ .$hostname != . -a .$host != . -a .$dom1 != . -a .$dom2 != . ]
do
echo $n "* Enter your fully qualified domain name [no default]:$c "
read hostname
host=`echo $hostname|awk -F. '{print $1}'`
dom1=`echo $hostname|awk -F. '{print $2}'`
dom2=`echo $hostname|awk -F. '{print $3}'`
done
######
# ask for nick --Ends
#####
;;
n|N)
echo "Exiting..Better luck next time!"
exit 1
;;
*)
echo ""
echo "Illegal choice"
esac
###
# allow file creation?
###
cat<<EOAF
Now you need to decide if you will allow the users to create datafiles
for them automatically. If you allow, the counter datafile will be
created for the user if it does not exist and a pre-determined counter
number will be inserted to it. If you do not allow, you have to create
the datafile for each user, provided that the data diectory has proper
write permission.
Allowing users to create datafile is very convenient, as you do not
have to be asked all the time when someone decides to use the counter.
But the dark side of this is, anyone will be able create datafiles in
the data directory. The decision is yours.
EOAF
echo $n "* Do you want to allow automatic file creation [[y|n]$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
do
echo $n "* Do you want to allow automatic file creation [[y|n]$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
done
case $answer in
y|Y)
alfc=1
;;
n|N)
alfc=0
;;
*)
echo ""
echo "Illegal choice"
esac
##
# compile in strict mode or not
###
cat <<EOSM
Now you need to decide if you want to compile the program in strict
mode. If you compile the program in strict mode, the browsers which
do not return the environment variable HTTP_REFERER, will not be
served, that is no access hit will be recorded, no time or date
will be displayed. Instead, a string 888888 will be displayed.
The strict mode ensures that your counter data file can not be messed
by accesing the counter remotely from a browser which does not return
that variable. Note, good browsers like netscape returns this
variable. Other browsers e.g. Mosaic does not return this variable in
IMG GET method at this time. This strict mode is experimental at this
time!
EOSM
echo $n "* Do you want the program to run in strict mode [[y|n]$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
do
echo $n "* Do you want the program to run in strict mode [[y|n]$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
done
case $answer in
y|Y)
strict=1
;;
n|N)
strict=0
;;
*)
echo ""
echo "Illegal choice"
esac
########
echo $n "* Do you want to ignore access hits from your own host [y|n]$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
do
echo $n "Do you want to ignore access from your own host [y|n]$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
done
case $answer in
y|Y)
ignc=1
;;
n|N)
ignc=0
;;
*)
echo ""
echo "Illegal choice"
esac
##
# allow to use color name datase? --starts
##
cat<<EORG
Ok, do you want the users to use the file rgb.txt for color name
lookup? It is very inefficient to search this file every time the
web page is loaded. If you answer yes, the color name
will be looked up and used. If you answer no, the color will be
looked up but instead of the counter image, the RGB value will
be displayed and the user will be asked to use the RGB value
instead. This will prevent users to use this file. However,
the convenience of allowing to use rgb.txt file is that color name e.g,
red, gold etc. can be used instead of cryptic red, green and blue
components of the color.
EORG
echo $n "* Allow using the rgb.txt file [y|n]$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
do
echo $n "* Allow using the rgb.txt file [y|n]$c? "
read answer
if [ .$answer = . ]
then
answer=x
fi
done
case $answer in
y|Y)
rgb=1
;;
n|N)
rgb=0
;;
*)
echo ""
echo "Illegal choice"
esac
##
# allow to use color name datase? --ends
##
##########
d=`date`
wh=`whoami`
hn=`hostname`
cat<<IGH>$ConfFile
#######
# configuratin file for Count $Version
# Automatically generated from user input by the script Gen-conf
# Created on: $d
# Edit by hand, if you need to add something
##############################################
####
# BLOCK 1
# Allow automatic datafile creation or not
# it's a required block. 1 means allow, 0 means do not allow.
####
IGH
if [ $alfc -eq 1 ]
then
echo "{" >> $ConfFile
echo "1" >> $ConfFile
echo "}" >> $ConfFile
else
echo "{" >> $ConfFile
echo "0" >> $ConfFile
echo "}" >> $ConfFile
fi
cat<<STM>>$ConfFile
###
# BLOCK 2
# run the program in strict mode or not.
# it's a required block. 1 means strict, 0 means not strict.
###
STM
if [ $strict -eq 1 ]
then
echo "{" >> $ConfFile
echo "1" >> $ConfFile
echo "}" >> $ConfFile
else
echo "{" >> $ConfFile
echo "0" >> $ConfFile
echo "}" >> $ConfFile
fi
cat<<BLOCK3>>$ConfFile
####
# BLOCK 3
# Allow to use RGB color database. 0 means allow, 1 means don't
# convenient to use because colorname e.g., red, gold etc can
# be used instead of rgb components of the color, however it's
# very inefficient to lookup.
####
BLOCK3
if [ $rgb -eq 1 ]
then
echo "{" >> $ConfFile
echo "1" >> $ConfFile
echo "}" >> $ConfFile
else
echo "{" >> $ConfFile
echo "0" >> $ConfFile
echo "}" >> $ConfFile
fi
cat<<IGH2>>$ConfFile
####
# BLOCK 4
# Ignore count block, you might want to ignore the local sites.
# If you do not want to ignore any hosts from
# counting, just put { on one line and } on the next line but make sure
# the braces exist!
# It's a required block.
######
# netmasks can be used to ignore a entire network or a specific
# range of hosts in the network. Read the counter documentation to
# know about netmasks.
IGH2
if [ $ignc -eq 1 ]
then
echo "{" >> $ConfFile
echo "$ipaddress" >> $ConfFile
echo "}" >> $ConfFile
else
echo "{" >> $ConfFile
echo "}" >> $ConfFile
fi
# generate auth block
cat<<EOBL>>$ConfFile
####
# BLOCK 5
# Auth block
# All possible names and IP addresses by which your host can be referred.
# These hosts can access the counter remotely or locally. Host running
# the http server must exist here.
##
EOBL
echo "{" >> $ConfFile
echo "$hostname" >> $ConfFile
echo "$host" >>$ConfFile
echo "$ipaddress" >> $ConfFile
if [ $nick -eq 1 ]
then
echo "$nickname" >> $ConfFile
echo "$nhost" >>$ConfFile
fi
echo "}" >>$ConfFile
cat <<EOCF
Created conf file "$ConfFile"
Please look at it, you might want to edit it!
EOCF